package connecteurs;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class Xml {

	public void lire_XML(String path_fichier) throws FileNotFoundException,
			SAXException, IOException, ParserConfigurationException {

		DocumentBuilderFactory builderFactory = DocumentBuilderFactory
				.newInstance();
		org.w3c.dom.Document doc = builderFactory.newDocumentBuilder().parse(
				new FileInputStream(path_fichier));
		@SuppressWarnings("unused")
		Node node;
		Element E, E_1;

		NodeList enseignants = ((org.w3c.dom.Document) doc)
				.getElementsByTagName("Enseignant");
		NodeList L;

		for (int index = 0; index < enseignants.getLength(); index++) {
			E = (Element) enseignants.item(index);

			L = E.getElementsByTagName("NumEns");
			E_1 = (Element) L.item(0);
			System.out.println("num enseignant " + E_1.getTextContent());

		}
	}

}
